<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
	use HasDateTimeFormatter;
    use SoftDeletes;

    protected $fillable = ['name', 'sex', 'school', 'class_name', 'birthdate', 'address', 'shop_id'];

    public function shop(){
        return $this->hasOne(Shop::class, 'id', 'shop_id');
    }

    public function bingshis(){
        return $this->hasMany(UserBingshi::class, 'user_id', 'id')->orderByDesc('id')->limit(15);
    }
    public function dangans(){
        return $this->hasMany(UserDangan::class, 'user_id', 'id')->with('wj')->orderByDesc('id')->limit(15);
    }


}
